From: Keir Fraser Date: Thu, 22 Apr 2010 08:41:36 +0000 (+0100) Subject: HAP 1GB: Add corner case handling for 1GB super page. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12320 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=af277a631b2c0f47c030cf6f8017ba70cb814a20;p=xen.git HAP 1GB: Add corner case handling for 1GB super page. - Without the check, guest memory allocation will never reach the boundary of a 1GB super page. Signed-off-by: Dongxiao Xu --- diff --git a/tools/libxc/xc_hvm_build.c b/tools/libxc/xc_hvm_build.c index f774978977..47486907be 100644 --- a/tools/libxc/xc_hvm_build.c +++ b/tools/libxc/xc_hvm_build.c @@ -203,6 +203,14 @@ static int setup_guest(int xc_handle, if ( count > max_pages ) count = max_pages; + /* Take care the corner cases of super page tails */ + if ( ((cur_pages & (SUPERPAGE_1GB_NR_PFNS-1)) != 0) && + (count > (-cur_pages & (SUPERPAGE_1GB_NR_PFNS-1))) ) + count = -cur_pages & (SUPERPAGE_1GB_NR_PFNS-1); + else if ( ((count & (SUPERPAGE_1GB_NR_PFNS-1)) != 0) && + (count > SUPERPAGE_1GB_NR_PFNS) ) + count &= ~(SUPERPAGE_1GB_NR_PFNS - 1); + /* Attemp to allocate 1GB super page. Because in each pass we only * allocate at most 1GB, we don't have to clip super page boundaries. */